package com.itheima.edu.day25DataGramDemo;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class ReceiveDemo {
    public static void main(String[] args) throws IOException {
        DatagramSocket ds = new DatagramSocket(10000);
        while(true) {
            byte[] bytes = new byte[1024];
            DatagramPacket dp = new DatagramPacket(bytes,bytes.length);
            ds.receive(dp);
            String data = new String(bytes,0,bytes.length);
            System.out.println(data);
            if("886".equals(data)){
                break;
            }
        }
        ds.close();
    }
}
